<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <fieldset class="layui-elem-field">
                <legend>充值活动</legend>
                <div class="layui-field-box">
                    <div class="layui-card">
                        <div class="layui-card-header">充值活动</div>
                        <div class="layui-card-body">
                            <div class="layui-form">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">活动开关</label>
                                    <div class="layui-input-inline">
                                        <input type="checkbox" name="status" value="1" lay-skin="switch" lay-text="开启|关闭" lay-filter="status" {eq name='find.status' value='1'}checked{/eq}>
                                    </div>
                                </div>
                                <div class="layui-form-item yin layui-hide">
                                    <label class="layui-form-label">活动名称</label>
                                    <div class="layui-input-inline" style="width: 300px;">
                                        <input type="text" name="name" value="{$find.name}" lay-verify="required" placeholder="活动名称" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item yin layui-hide">
                                    <label class="layui-form-label">活动时间</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="time" value="{$find.time}" class="layui-input" id="test6" placeholder=" - " autocomplete="off">
                                    </div>
                                </div>
                                <div class="layui-form-item yin layui-hide">
                                    <label class="layui-form-label">最低充值金额</label>
                                    <div class="layui-input-inline" style="width: 100px;">
                                        <input type="number" name="lowest" lay-verify="required" value="{$find.lowest}" placeholder="元" class="layui-input">
                                    </div>
                                    <div style="height: 38px;line-height: 38px;">元</div>
                                </div>
                                <div class="layui-form-item yin layui-hide">
                                    <label class="layui-form-label">赠送余额</label>
                                    <div class="layui-input-inline" style="width: 100px;">
                                        <input type="number" name="give" lay-verify="required" value="{$find.give}" placeholder="赠送余额" class="layui-input">
                                    </div>
                                    <div style="height: 38px;line-height: 38px;">% (用户充值金额的百分比)</div>
                                </div>
                                <div class="layui-form-item yin layui-hide">
                                    <label class="layui-form-label">返现余额</label>
                                    <div class="layui-input-inline" style="width: 100px;">
                                        <input type="number" name="cashback" lay-verify="required" value="{$find.cashback}" placeholder="返现余额" class="layui-input">
                                    </div>
                                    <div style="height: 38px;line-height: 38px;">% (用户充值金额的百分比)</div>
                                </div>
                                <!--<div class="layui-form-item">-->
                                    <!--<label class="layui-form-label">提供礼品商家是否要缴纳保证金</label>-->
                                    <!--<div class="layui-input-inline" style="width: 100px;">-->
                                        <!--<input type="checkbox" name="zzz" lay-skin="switch" lay-text="开启|关闭">-->
                                    <!--</div>-->
                                <!--</div>-->
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button class="layui-btn" lay-submit lay-filter="set_website">确认保存</button>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
            </fieldset>
        </div>
    </div>
</div>

<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'set', 'laydate'], function(){
        var $ = layui.jquery,
            form = layui.form,
            laydate = layui.laydate;

        //日期范围
        laydate.render({
            elem: '#test6'
            ,range: true
        });

        var status = "{$find.status}";
        if (status == 1){
            $('.yin').removeClass('layui-hide');
        }

        form.on('switch(status)', function(data){
            var checked = data.elem.checked;
            if (checked){
                $('.yin').removeClass('layui-hide');
            }else{
                $('.yin').addClass('layui-hide');
            }
        });

        form.on('submit(set_website)', function(data){
            var field = data.field;
            $.post("{:url('Activity/recharge')}", {field:field}, function(e){
                if (e == 1){
                    layer.msg('修改成功', {icon: 1});
                }else{
                    layer.msg('修改失败', {icon: 2});
                }
            })
        });

    });
</script>
</body>
</html>